﻿package com.wandian.view.components.ui
{
	import com.wandian.ApplicationFacade;
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.vo.PlayerVo;
	import com.wandian.model.vo.RoomVo;
	import com.wandian.util.CLZButton;
	
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;

    public class RoomPlayerInfoMc extends EventDispatcher
    {
        private var _mcInfo:MovieClip;
        private var _type:String;
        private const UP:int = 1;
        private const OVER:int = 2;
        private const DOWN:int = 3;
        private var _playerVo:PlayerVo;
        private var _facade:ApplicationFacade;
        private var _global:GameData;

        public function RoomPlayerInfoMc(param1:MovieClip, param2:PlayerVo)
        {
            this._facade = ApplicationFacade.getInstance();
            this._global = GameData.getInstance();
            this._playerVo = param2;
            this._mcInfo = param1;
            this._mcInfo.gotoAndStop(this.UP);
            this._mcInfo.buttonMode = true;
            this._mcInfo.doubleClickEnabled = true;
            this._mcInfo.addEventListener(MouseEvent.ROLL_OUT, this.outHandler);
            this._mcInfo.addEventListener(MouseEvent.ROLL_OVER, this.overHandler);
            this._mcInfo.addEventListener(MouseEvent.CLICK, this.onHandler);
            this._mcInfo["name_txt"].text = param2.name;
            CLZButton.setButton(this._mcInfo["kick_btn"], GameData.tip["TICK_BTN"]);
            CLZButton.setButton(this._mcInfo["banSpeak_btn"], GameData.tip["BAN_SPEAK"]);
            CLZButton.setButton(this._mcInfo["giveGift_btn"], GameData.tip["GIVE_GIFT_BTN"]);
            this._mcInfo["kick_btn"].addEventListener(MouseEvent.CLICK, this.onKickHandler);
            this._mcInfo["banSpeak_btn"].addEventListener(MouseEvent.CLICK, this.onBanSpeakHandler);
            this._mcInfo["giveGift_btn"].addEventListener(MouseEvent.CLICK, this.onGiveGiftHandler);
            this.outHandler();
            return;
        }

        private function onKickHandler(event:MouseEvent) : void
        {
            var _loc_2:String = null;
            var _loc_3:Object = null;
            if (this._global.userInfo.userVo.vip < this._playerVo.vip)
            {
                _loc_2 = GameData.tip["NOT_VIP_TIP_BANK"];
                _loc_3 = {okNoticeName:CLZNoticeName.ON_PAY_VIP, tip:_loc_2, tipTitle:GameData.tip["SYSTEM_TIP"], isCancel:true, okTip:"ON_PAY_VIP_NAME", cancelTip:"I_KNOW", isSendClose:false};
                this._facade.sendNotification(CLZNoticeName.SHOW_WINDOWS_TIP, _loc_3);
                return;
            }
            this._facade.sendNotification(CLZNoticeName.SHOW_USE_SELECTED_TIP, {pcate:GameData.PROP_PCATE_ID_1, pframe:GameData.PROP_KICK_PFRAME_ID, playerVo:this._playerVo});
            this.dispatchEvent(new Event(Event.CHANGE));
            return;
        }

        private function onBanSpeakHandler(event:MouseEvent) : void
        {
            var _loc_2:String = null;
            var _loc_3:Object = null;
            if (this._global.userInfo.userVo.vip < this._playerVo.vip)
            {
                _loc_2 = GameData.tip["NOT_VIP_TIP_BANK"];
                _loc_3 = {okNoticeName:CLZNoticeName.ON_PAY_VIP, tip:_loc_2, tipTitle:GameData.tip["SYSTEM_TIP"], isCancel:true, okTip:"ON_PAY_VIP_NAME", cancelTip:"I_KNOW", isSendClose:false};
                this._facade.sendNotification(CLZNoticeName.SHOW_WINDOWS_TIP, _loc_3);
                return;
            }
            this._facade.sendNotification(CLZNoticeName.SHOW_USE_SELECTED_TIP, {pcate:GameData.PROP_PCATE_ID_1, pframe:GameData.PROP_BANSPEAK_PFRAME_ID, playerVo:this._playerVo});
            this.dispatchEvent(new Event(Event.CHANGE));
            return;
        }

        private function onGiveGiftHandler(event:MouseEvent) : void
        {
            this._facade.sendNotification(CLZNoticeName.SHOW_SHOPING_GIFT, this._playerVo);
            this.dispatchEvent(new Event(Event.CHANGE));
            return;
        }

        private function onHandler(event:MouseEvent) : void
        {
            this._mcInfo.gotoAndStop(this.DOWN);
            return;
        }

        private function outHandler(event:MouseEvent = null) : void
        {
            this._mcInfo.gotoAndStop(this.UP);
            this._mcInfo["kick_btn"].visible = false;
            this._mcInfo["banSpeak_btn"].visible = false;
            this._mcInfo["giveGift_btn"].visible = false;
            return;
        }

        private function overHandler(event:MouseEvent) : void
        {
            this._mcInfo.gotoAndStop(this.OVER);
            if (this._global.userInfo.userVo.userid == this._playerVo.userid)
            {
                return;
            }
            this._mcInfo["kick_btn"].visible = true;
            this._mcInfo["banSpeak_btn"].visible = true;
            this._mcInfo["giveGift_btn"].visible = true;
            return;
        }

    }
}
